package com.blockmeta.bbs.baselibrary.utils.loading;

import android.app.Dialog;
import android.content.Context;
import android.graphics.drawable.AnimationDrawable;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;

import com.blockmeta.bbs.baselibrary.R;

/**
 * @author AirThor
 * @date 2020/4/10.
 */
public class PopProgressBar extends Dialog {
    public static PopProgressBar getInstance(Context context){
        return new PopProgressBar(context,R.style.Progress);
    }

    private PopProgressBar(Context context, int themeResId) {
        super(context, themeResId);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        View popupView = LayoutInflater.from(getContext()).inflate(R.layout.pop_progress, null);
        setContentView(popupView);
        ImageView imageView = popupView.findViewById(R.id.ivLoading);
        // 加载动画
        AnimationDrawable animationDrawable = (AnimationDrawable) imageView.getBackground();
        // 使用ImageView显示动画
        animationDrawable.stop();
        animationDrawable.start();
    }
}
